package cn.dlc.com.tree;

import cn.dlc.com.queue.Queue;

/**
 * @author 邓立川
 * @date 2021/3/22 21:19
 * @desc 当前类的描述信息
 */
public class BinaryTreeTest {
    public static void main(String[] args) {
        testErgodic();

    }

    private static void testErgodic(){
        BinaryTree<String, String> tree = new BinaryTree<>();

        tree.put("E","5");
        tree.put("B","2");
        tree.put("G","7");
        tree.put("A","1");
        tree.put("D","4");
        tree.put("F","6");
        tree.put("H","8");
        tree.put("C","3");

        Queue<String> pres = tree.preErgodic();
        for (String string : pres) {
            System.out.print(tree.get(string));
        }
        System.out.println("\t\n-------------");
        Queue<String> mid = tree.midErgodic();
        for (String string : mid) {
            System.out.print(tree.get(string));
        }
        System.out.println("\t\n-------------");
        Queue<String> last = tree.lastErgodic();
        for (String string : last) {
            System.out.print(tree.get(string));
        }

        System.out.println("\t\n-------------");
        Queue<String> layer = tree.layerErgodic();
        for (String string : layer) {
            System.out.print(tree.get(string));
        }
        System.out.println();
        System.out.println("tree.maxDepth() " + tree.maxDepth());
    }

    private static void testNormal(){
        BinaryTree<Integer, String> tree = new BinaryTree<>();

        tree.put(2,"rose");
        tree.put(1,"jack");
        tree.put(3,"jame");

        System.out.println("元素个数： " + tree.size());

        System.out.println("key=2的值是" + tree.get(2));

        tree.delete(3);
        System.out.println("删除后元素个数： " + tree.size());
    }
}
